package com.exam.service.impl;


import com.exam.dao.IUserCheckDao;
import com.exam.entity.Student;
import com.exam.service.UserCheckService;
import com.exam.util.Encrypt;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class UserCheckServiceImpl implements UserCheckService {

	@Resource
	private IUserCheckDao IUserCheckDao;

	/**
	 * 测试MD5加密
	 * @param args
	 */
	public static void main(String[] args) {
//		System.out.println(Encrypt.md5("admin"));
	}

	/**
	 * 管理员登录，解密登录
	 * @param userName
	 * @param password
	 * @return
	 */
	@Override
	public int checkAdmin(String userName, String password) {
		password = Encrypt.md5(password);//对密码进行加密操作
		int res = IUserCheckDao.checkAdmin(userName,password);
		return res;
	}

	/**
	 * 学生登录
	 * @param sno
	 * @param password
	 * @return
	 */
	@Override
	public List<Student> checkStudent(String sno, String password) {
		password = Encrypt.md5(password);
		List<Student> res = IUserCheckDao.checkStudent(sno,password);
		return res;
	}

	/**
	 * 修改学生密码
	 * @param sno
	 * @param password
	 * @return
	 */
	@Override
	public int modifyStuPwd(String sno, String password) {
		password = Encrypt.md5(password);
		return IUserCheckDao.modifyStuPwd(sno,password);
	}

	public void setIUserCheckDao(com.exam.dao.IUserCheckDao IUserCheckDao) {
		this.IUserCheckDao = IUserCheckDao;
	}
}
